using System.Collections.Generic;
using Pegasus.Data.SqlClient;
using RollManager.Library.Utils;

namespace RollManager.Library
{
    partial class Database
    {
        public static List<ConfigSetting> GetConfigSettings()
        {
            return runMapper<ConfigSetting>( "GetConfigSettings" );
        }

        public static int GetUserId( string UserName )
        {
            using( SqlDatabaseAccess access = s_dbConnection.CreateDatabaseAccess() )
            {
                return (int) access.StoredProcScalar( "GetUserId", UserName );
            }
        }

        public static string GetUserSetting( string setting, int userId )
        {
            using( SqlDatabaseAccess access = s_dbConnection.CreateDatabaseAccess() )
            {
                return (string) access.StoredProcScalar( "GetUserSetting", userId, setting );
            }
        }

        public static string GetUserSetting( int configSettingId )
        {
            using( SqlDatabaseAccess access = s_dbConnection.CreateDatabaseAccess() )
            {
                return (string) access.StoredProcScalar( "GetUserSettingBySettingId", Common.UserId, configSettingId );
            }
        }

        public static void SaveUserSetting( int configSettingId, string setting )
        {
            runQuery( "SaveUserSetting", Common.UserId, configSettingId, setting );
        }
    }
}
